<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
	<META HTTP-EQUIV="CONTENT-TYPE" CONTENT="text/html; charset=utf-8">
	<TITLE>XMI to XML Schema Transformation Rules</TITLE>
	<META NAME="GENERATOR" CONTENT="OpenOffice.org 2.0  (Linux)">
	<META NAME="AUTHOR" CONTENT="Anthony Coates">
	<META NAME="CREATED" CONTENT="20070425;22244900">
	<META NAME="CHANGEDBY" CONTENT="Anthony Coates">
	<META NAME="CHANGED" CONTENT="20070426;14543000">
	<STYLE TYPE="text/css">
	<!--
		H1.western { font-family: "Arial", sans-serif }
		P.western { font-family: "Arial", sans-serif }
		H3.heading-2-western { color: #800000; font-family: "Arial", sans-serif; font-size: 18pt }
		H3.heading-2-cjk { color: #800000; font-family: "Arial"; font-size: 18pt }
		H3.heading-2-ctl { color: #800000; font-family: "Arial"; font-size: 18pt }
		STRONG { color: #800000 }
		STRONG.western { font-family: "Arial", sans-serif; so-language: en-GB }
	-->
	</STYLE>
</HEAD>
<BODY LANG="en-GB" DIR="LTR">
<H1 CLASS="western">XMI to XML Schema Transformation Rules</H1>
<P CLASS="western">Anthony B. Coates, <A HREF="mailto:abcoates@mileywatts.com">abcoates@mileywatts.com</A>,
UK</P>
<P CLASS="western">25<SUP>th</SUP> April, 2007.</P>
<H3 CLASS="heading-2-western">Introduction</H3>
<P CLASS="western">This document describes the XMI to XML Schema
transformation rules implemented by the example transformation files</P>
<UL>
	<LI><P CLASS="western"><A HREF="ontology-to-intermediate.xq">ontology-to-intermediate.xq</A>
	– transforms XMI to the simple intermediate XML representation
	validated by <A HREF="ontology-to-physical-intermediate.xsd">ontology-to-physical-intermediate.xsd</A>;</P>
	<LI><P CLASS="western"><A HREF="intermediate-to-xml-schema.xsl">intermediate-to-xml-schema.xsl</A>
	– transforms the simple intermediate XML representation into a
	number of message Schemas.</P>
</UL>
<P CLASS="western">These transformations provide examples of
transformation rules that could be used for future versions of ISO
20022.</P>
<H3 CLASS="heading-2-western">XMI to Intermediate XML Transformation
Rules</H3>
<P CLASS="western">XMI 2.1, as exported by MagicDraw, is assumed.</P>
<OL>
	<LI><P CLASS="western">Create a &lt;msg:MessageSet&gt; element as
	the root element of the intermediate XML;</P>
	<LI><P CLASS="western"><STRONG CLASS="western"><FONT COLOR="#800000">[not
	implemented]</FONT></STRONG> Only process XMI definitions that occur
	within a model with the ISO 20022 &laquo;model&raquo; stereotype;</P>
	<LI><P CLASS="western">Process each &lt;ownedMember&gt; element in
	the ISO 20022 model(s) in turn;</P>
	<LI><P CLASS="western">Separate the &lt;ownedMember&gt; elements
	into different definition types:</P>
	<UL>
		<LI><P CLASS="western"><STRONG CLASS="western">models</STRONG> are
		&lt;ownedMember&gt; definitions where 'xmi:type' is 'uml:Model';</P>
		<LI><P CLASS="western"><STRONG CLASS="western">profiles</STRONG>
		are &lt;ownedMember&gt; defintions where 'xmi:type' is
		'uml:Profile';</P>
		<LI><P CLASS="western"><STRONG CLASS="western">packages</STRONG>
		are &lt;ownedMember&gt; definitions where 'xmi:type' is
		'uml:Package';</P>
		<LI><P CLASS="western"><STRONG CLASS="western">messages</STRONG>
		are &lt;ownedMember&gt; definitions where 'xmi:type' is
		'uml:Class', the name is non-empty, and the defined class is a base
		class of a '<FONT FACE="SansSerif, sans-serif"><FONT COLOR="#000000">UnifiOntologyMetamodel:message'
		definition;</FONT></FONT></P>
		<LI><P CLASS="western"><FONT FACE="SansSerif, sans-serif"><FONT COLOR="#000000"><STRONG CLASS="western">message
		components</STRONG> are &lt;ownedMember&gt; definitions where
		'xmi:type' is 'uml:Class', the name is non-empty, and the defined
		class is not a message class;</FONT></FONT></P>
		<LI><P CLASS="western"><FONT FACE="SansSerif, sans-serif"><FONT COLOR="#000000"><STRONG CLASS="western">data
		types</STRONG> are &lt;ownedMember&gt; definitions where 'xmi:type'
		is 'uml:DataType';</FONT></FONT></P>
		<LI><P CLASS="western"><FONT FACE="SansSerif, sans-serif"><FONT COLOR="#000000"><STRONG CLASS="western">primitive
		types</STRONG> are &lt;ownedMember&gt; definitions where 'xmi:type'
		is 'uml:PrimitiveType';</FONT></FONT></P>
		<LI><P CLASS="western"><FONT FACE="SansSerif, sans-serif"><FONT COLOR="#000000"><STRONG CLASS="western">associations</STRONG>
		are &lt;ownedMember&gt; definitions where 'xmi:type' is
		'uml:Association';</FONT></FONT></P>
		<LI><P CLASS="western"><FONT FACE="SansSerif, sans-serif"><FONT COLOR="#000000"><STRONG CLASS="western">comments</STRONG>
		are &lt;ownedMember&gt; definitions where 'xmi:type' is
		'uml:Comment';</FONT></FONT></P>
		<LI><P CLASS="western"><FONT FACE="SansSerif, sans-serif"><FONT COLOR="#000000"><STRONG CLASS="western">generalizations</STRONG>
		are &lt;ownedMember&gt; definitions where 'xmi:type' is
		'uml:Generalization';</FONT></FONT></P>
		<LI><P CLASS="western"><FONT FACE="SansSerif, sans-serif"><FONT COLOR="#000000"><STRONG CLASS="western">literal
		integers</STRONG> are &lt;ownedMember&gt; definitions where
		'xmi:type' is 'uml:LiteralInteger';</FONT></FONT></P>
		<LI><P CLASS="western"><FONT FACE="SansSerif, sans-serif"><FONT COLOR="#000000"><STRONG CLASS="western">properties</STRONG>
		are &lt;ownedMember&gt; definitions where 'xmi:type' is
		'uml:Property';</FONT></FONT></P>
		<LI><P CLASS="western"><FONT FACE="SansSerif, sans-serif"><FONT COLOR="#000000"><STRONG CLASS="western">stereotypes</STRONG>
		are &lt;ownedMember&gt; definitions where 'xmi:type' is
		'uml:Stereotype';</FONT></FONT></P>
	</UL>
	<LI><P CLASS="western">For each <STRONG CLASS="western">message</STRONG>,
	generate a &lt;Message&gt; element in the intermediate XML. Add
	attributes and child elements with the name, the package, whether
	the message class is abstract, the documentation (comments), and the
	ancestor classes from which the message class is derived;</P>
	<LI><P CLASS="western">For each <STRONG CLASS="western">property</STRONG>
	in the message class, generate an &lt;Element&gt; element within the
	&lt;Message&gt; element. Add attributes and child elements with the
	name, type name and type package, minimum and maximum occurrences,
	and documentation (comments);</P>
	<LI><P CLASS="western">For each <STRONG CLASS="western">message
	component</STRONG>, generate a &lt;MessageComponent&gt; element in
	the intermediate XML. Then do the same as for a <STRONG CLASS="western">message</STRONG>
	(see #5 and #6);</P>
	<LI><P CLASS="western">For each <STRONG CLASS="western">data type</STRONG>,
	generate a &lt;DataType&gt; element in the intermediate XML. Add
	attributes and child elements with the name, the package, whether
	the data type class is abstract, the documentation (comments), and
	the ancestor classes from which the message class is derived;</P>
	<LI><P CLASS="western">For each <STRONG CLASS="western">primitive
	type</STRONG>, generate a &lt;PrimitiveType&gt; element in the
	intermediate XML. Add attributes and child elements with the name,
	the package, whether the primitive type class is abstract, the
	documentation (comments), and the ancestor classes from which the
	message class is derived.</P>
</OL>
<H3 CLASS="heading-2-western">Intermediate XML to XML Schema
Transformation Rules</H3>
<OL>
	<LI><P CLASS="western">For each &lt;Message&gt; element that isn't
	marked as abstract, generate a separate message XML Schema;</P>
	<LI><P CLASS="western">Create a namespace URI for the Schema by
	prepending a URI prefix to the message name;</P>
	<LI><P CLASS="western">Locate all of the definitions in the
	intermediate XML on which the message has a dependency.  The
	following steps are applied only to those definitions on which the
	message has a dependency;</P>
	<LI><P CLASS="western">Create a global root element definition
	&lt;Document&gt; and a matching global complex type
	'MessageDocument';</P>
	<LI><P CLASS="western">In the 'MessageDocument' complex type, create
	a single local element whose name is the message name, and whose
	complex type has the name of the message name;</P>
	<LI><P CLASS="western">For each &lt;Message&gt; and
	&lt;MessageComponent&gt; in the intermediate XML, create a global
	complex type with the same name as the message/component. If the
	message/component has a base class, make the complex type an
	extension of the complex type for the base class;</P>
	<LI><P CLASS="western">For each &lt;Element&gt; definition in a
	&lt;Message&gt; or &lt;MessageComponent&gt;, create a local element
	definition in the complex type for the message/component, and set
	the type and minimum/maximum occurrences of the local element
	appropriately;</P>
	<LI><P CLASS="western"><STRONG CLASS="western">[incomplete]</STRONG>
	For each &lt;DataType&gt; definition, create a matching global
	complex type, using extension of the complex type of the base class
	if applicable;</P>
	<LI><P CLASS="western"><STRONG CLASS="western">[incomplete]</STRONG>
	For each &lt;PrimitiveType&gt; definition, insert the matching
	global simple type definition. The set of primitive types is defined
	and constrained as part of the ISO 20022 spec, and so these
	definitions are inserted rather than generated from the information
	in the intermediate XML.</P>
</OL>
</BODY>
</HTML>